import { defineStore } from "pinia";
import { store } from "../index";
class loginState {
  isLogin = false;
  isStatus = 1;
  userInfo = {};
  imageUrl = "";
}
// 定义store
export const useLoginStore = defineStore("login", {
  state: () => new loginState(),
  getters: {
    getUserInfo() {
      return this.userInfo;
    },
  },
  actions: {
    setLogin() {
      this.isLogin = true;
    },
    setLogout() {
      this.isLogin = false;
    },
    setUserInfo(user) {
      this.$patch({
        userInfo: user,
      });
    },
    setStatus(val) {
      this.isStatus = val;
    },
    init() {
      this.imageUrl = "";
    },
  },
});
export const useUserStoreWithOut = () => {
  return useLoginStore(store);
};
